package cc.zy.base.hr.service.impl;

import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.hr.entity.StaffSyncLog;
import cc.zy.base.hr.mapper.StaffSyncLogMapper;
import cc.zy.base.hr.service.IStaffSyncLogService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ljy
 * @time 2022/03/09 21:07:07
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class StaffSyncLogServiceImpl extends ServiceImpl<StaffSyncLogMapper, StaffSyncLog> implements IStaffSyncLogService {

    @Autowired
    private StaffSyncLogMapper logMapper;

    @Override
    public void createStaffSyncLog(StaffSyncLog staffSyncLog) {
        logMapper.createStaffSyncLog(staffSyncLog);
    }

    @Override
    public IPage<StaffSyncLog> getStaffSyncLogs(QueryRequest request, StaffSyncLog staffSyncLog) {
        Page<StaffSyncLog> page = new Page<>(request.getPageNum(), request.getPageSize());
        page.setSearchCount(false);
        page.setTotal(baseMapper.countStaffSyncLogDetail(staffSyncLog));
        //SortUtil.handlePageSort(request, page, "id", FebsConstant.ORDER_ASC, false);
        return baseMapper.getStaffSyncLogDetailPage(page, staffSyncLog);
    }

    @Override
    public StaffSyncLog getStaffSyncLogById(Integer logId) {
        return logMapper.getStaffSyncLogById(logId);
    }
}
